<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/template.xhtml">

    <ui:define name="content">
        <h:form id="formConsulta">
            <p:growl id="messages" showDetail="true" life="10000"/>
            <p:fieldset legend="Filtros de busqueda de controles">

                <h:panelGrid columns="2" style="width: 100%">
                      
                        <ui:define name="label">#{msg.numeroHistoria}:</ui:define>
                        <p:inputText value="#{administrarControlAction.persona.numDocumento}" disabled="true"/>
                    

                      
                        <ui:define name="label">#{msg.numeroIdentificacion}:</ui:define>
                        <p:inputText value="#{administrarControlAction.persona.numDocumento}" disabled="true"/>
                    

                      
                        <ui:define name="label">#{msg.tipoIdentificacion}</ui:define>
                        <p:inputText value="#{administrarControlAction.persona.tTipDocumento.desTipDocumento}" disabled="true"/>
                    

                      
                        <ui:define name="label">#{msg.nombre}:</ui:define>
                        <p:inputText value="#{administrarControlAction.persona.desPrinombre}" disabled="true"/>
                    

                      
                        <ui:define name="label">#{msg.fechaIni}:</ui:define>
                        <p:calendar id="fechaIni" onclick="putInitialFormat(this)" onkeyup="maskFunction(this, event)" converterMessage="#{msg.formatoFechaInvalido}" navigator="true" value="#{administrarControlAction.fechaInicial}"  >
                        </p:calendar>
                    

                      
                        <ui:define name="label">#{msg.fechaFin}:</ui:define>
                        <p:calendar id="fechaFin" onclick="putInitialFormat(this)" onkeyup="maskFunction(this, event)" converterMessage="#{msg.formatoFechaInvalido}"
                                    navigator="true" value="#{administrarControlAction.fechaFinal}" >
                        </p:calendar>
                                   
                </h:panelGrid>  

                
                    <p:commandButton value="#{msg.consultar}"  action="#{administrarControlAction.buscarControl}" update="formConsulta" />
                    <p:commandButton value="#{msg.atras}"  action="#{administrarControlAction.cancelar}"  immediate="true"/>
                

            </p:fieldset>
            <p:fieldset legend="#{msg.resultados}">
                <p:dataTable id="tablaResultado" paginator="true" rows="10" value="#{administrarControlAction.listaControl}" var="item"
                             rendered="#{administrarControlAction.listaControl != null}">


                    <p:column sortBy="#{item.idControl}">
                        <f:facet name="header">
                            <h:outputText value="#{msg.numeroControl}"/>
                        </f:facet>
                        <h:outputText value="#{item.idControl}" />
                    </p:column>

                    <p:column sortBy="#{item.feControl}">
                        <f:facet name="header">
                            <h:outputText value="#{msg.feControl}"/>
                        </f:facet>
                        <h:outputText value="#{item.feControl}" >
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>

                    <p:column sortBy="#{item.desMotconsulta}">
                        <f:facet name="header">
                            <h:outputText value="#{msg.motivoConsulta}"/>
                        </f:facet>
                        <h:outputText value="#{item.desMotconsulta}" />
                    </p:column>

                    <p:column sortBy="#{item.feUltcontrol}">
                        <f:facet name="header">
                            <h:outputText value="#{msg.proximoControl2}"/>
                        </f:facet>
                        <h:outputText value="#{item.feUltcontrol}" >
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <p:commandButton icon="ui-icon-plus" title="#{msg.crearControl}" immediate="true"
                                             action="#{administrarControlAction.crearControl()}" update=":formConsulta" />
                        </f:facet>

                        <p:commandButton icon="ui-icon-pencil" title="#{msg.modificarControl}" action="#{administrarControlAction.modificarControl(item)}"  immediate="true" update=":formConsulta"/>
                        <p:commandButton icon="ui-icon-zoomin" title="#{msg.consultarDetalleControl}" action="#{consultarDetalleControlAction.init(item,administrarControlAction.persona)}" immediate="true"/>
                        <p:commandButton icon="ui-icon-trash" title="#{msg.eliminarControl}" action="#{administrarControlAction.eliminar(item)}" />
                    </p:column>

                </p:dataTable>
                <h:inputHidden id="controlCrear" value="#{administrarControlAction.controlCrear}"/>
            </p:fieldset>    
        </h:form>

    </ui:define>

</ui:composition>
